/**
 * 
 */

function $(id) {
	return document.getElementById(id);
}

window.onload = function() {
	var Obtn = $("login");
	var Oname = $("name");
	var Opassword = $("password");
	var Ocheckbox = $("remember");
	Obtn.onclick = function() {
		if (Ocheckbox.checked) {
			setCookie("name", Oname, 10);
			setCookie("password", Opassword, 10);
			setCookie("remember", "1", 10);
		} else {
			setCookie("name", "", -1);
			setCookie("password", "", -1);
			setCookie("remember", "", -1);
		}		
		var chk = getCookie("remember");
		if (chk = "1") {
			Ocheckbox.checked = true;
			Oname.value = getCookie("name");
			Opassword.value = getCookie("password");
		}
	}
}

function setCookie(name, value, time) {
	var exdate = new Date()
	exdate.setDate(exdate.getDate() + time)
	document.cookie = name + "=" + escape(value)
			+ ((time == null) ? "" : ";time=" + exdate.toGMTString())
}

function getCookie(name) {
	var start = document.cookie.indexOf(name + "=");
	start = start + name.length + 1;
	var end = document.cookie.indexOf(":", start);
	if (end == -1)
		end = document.cookie.length;
	var str = document.cookie.substring(start, end);
	return str;
}


		

